

.text
 .globl main
fact:
	addi sp, sp, -1648
	sw s0, 1644(sp)
	addi s0, sp, 1648
	sw a0, -8(s0)
	sw ra, -12(s0)
entry_fact:
	lw t5, -8(s0) # reload Varn -- spill_var
	li t6, 1 # tmp load imm 
	sgt a3, t5, t6
	xori a3, a3, 1
	bnez a3, L0
	j L1
L0:
	li a0, 1
	lw ra, -12(s0)
	lw s0, 1644(sp)
	addi sp, sp, 1648
	ret
L1:
	lw t5, -8(s0) # reload Varn -- spill_var
	addi a1, t5, -1
	sw a2, -16(s0)  # save caller-saved t2
	mv a0, a1
	call fact
	mv t5, a0 # move a0 to temp_reg
	lw a2, -16(s0)  # restore caller-saved t2
	mv a2, t5  # move return value from temp_reg t5
	lw t5, -8(s0) # reload Varn -- spill_var
	mul a0, t5, a2
	lw ra, -12(s0)
	lw s0, 1644(sp)
	addi sp, sp, 1648
	ret

main:
	addi sp, sp, -1648
	sw s0, 1644(sp)
	addi s0, sp, 1648
	sw ra, -8(s0)
entry_main:
	sw a0, -12(s0)  # save caller-saved t4
	li a0, 5
	call fact
	mv t5, a0 # move a0 to temp_reg
	lw a0, -12(s0)  # restore caller-saved t4
	mv a0, t5  # move return value from temp_reg t5
	lw ra, -8(s0)
	lw s0, 1644(sp)
	addi sp, sp, 1648
	ret

